﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Collections;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Hashtable ht = new Hashtable();
            ht.Add("Key1", "Lasagna");
            ht.Add("Key2", "Spaghetti");
            ht.Add("Key3", "Pizza");

            ListBox1.DataSource = ht;
            DropDownList1.DataSource = ht;
            CheckBoxList1.DataSource = ht;
            RadioButtonList1.DataSource = ht;

            Page.DataBind();
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Result.Text += "- Item selected in Listbox1: " + ListBox1.SelectedItem.Text + " - " + ListBox1.SelectedItem.Value + "<br />";
        
        Result.Text += "- Item selected in DropdownList1: " + DropDownList1.SelectedItem.Text + " - " + DropDownList1.SelectedItem.Value + "<br />";
        
        Result.Text += "- Item selected in OptionList1: " + RadioButtonList1.SelectedItem.Text + " - " + RadioButtonList1.SelectedItem.Value + "<br />";
        
        Result.Text += "- Items selected in CheckList1: ";
        foreach (ListItem li in CheckBoxList1.Items)
        {
            if (li.Selected)
                Result.Text += li.Text + " - " + li.Value + " ";
        }
    }
}
